<B>This page contains popup menu used for selecting a page or URL</B>
<P>
Please note that JavaScript is currently only available in Netscape Navigator 2.0 or later, and in Internet Explorer for MacOS version 3.0.1 or later. <FONT COLOR="931B15">Do not assume that all in your audience are using a JavaScript enabled browser.</FONT>
<HR>
Here is an example on how JavaScript can be used in a form with a popup menu that has links to other pages.
NOTE: The pages may fail to load when using this example with Internet Explorer and the pages to be loaded are stored on your local disk. It should work correctly with pages stored on a Web-server though.
Change the links and text to be displayed in the menu by editing the lines containing the <CODE>OPTION</CODE> tags. Note that you can also use full URL's in the VALUE attribute.
<P>
Change the text of the button in the Value attribute of <BR>
<CODE> <INPUT TYPE=BUTTON VALUE="Go"</CODE> ...
</BLOCKQUOTE>
<HR>
<P>
<B>Programming notes</B>
<BLOCKQUOTE>
The actual JavaScript is in the button's onClick handler. The JavaScript array <CODE>this.form.menu.options</CODE> is an array of the option tags (with its contents) in the form named "menu". To find which menu item that is selected we can use the property <CODE>this.form.menu.selectedIndex</CODE>, that holds the index of the selected item.
<P>
We then get the name of the page by accessing the value attribute of the selected item in the array with the expression <CODE>this.form.menu.options[this.form.menu.selectedIndex].value</CODE>.
<P>
<CODE>top.location.href</CODE> is the address of the url to be displayed in the window. Since we set <CODE>top.location</CODE> to contain the new pages URL, the new page will be displayed in the entire window, even if our page is inside a frame. To get a page to be displayed in a specific frame is an exercise left to the reader <FONT SIZE="-2" FACE="Monaco, Courier">;-)</FONT>. (You can also check out the Programming notes for the <A HREF="PopupMenu2">second JavaScript Popup Menu</A> to get a hint).